@featurevisor/sdk
Advanced tools
Comparing version 0.46.0 to 0.46.1
@@ -6,2 +6,10 @@ # Change Log | ||
## [0.46.1](https://github.com/fahad19/featurevisor/compare/v0.46.0...v0.46.1) (2023-08-31) | ||
**Note:** Version bump only for package @featurevisor/sdk | ||
# [0.46.0](https://github.com/fahad19/featurevisor/compare/v0.45.0...v0.46.0) (2023-08-27) | ||
@@ -8,0 +16,0 @@ |
{ | ||
"name": "@featurevisor/sdk", | ||
"version": "0.46.0", | ||
"version": "0.46.1", | ||
"description": "Featurevisor SDK for Node.js and the browser", | ||
@@ -49,3 +49,3 @@ "main": "dist/index.js", | ||
}, | ||
"gitHead": "2404707e0f8506be540726a372c06abe116b7152" | ||
"gitHead": "72e76ad467f285c156fcfc0bf01bb066dd549da9" | ||
} |
@@ -42,2 +42,106 @@ import { allConditionsAreMatched } from "./conditions"; | ||
it("should match with operator: startsWith", function () { | ||
const conditions: Condition[] = [ | ||
{ | ||
attribute: "name", | ||
operator: "startsWith", | ||
value: "Hello", | ||
}, | ||
]; | ||
// match | ||
expect(allConditionsAreMatched(conditions, { name: "Hello World" })).toEqual(true); | ||
expect(allConditionsAreMatched(conditions, { name: "Hello Universe" })).toEqual(true); | ||
// not match | ||
expect(allConditionsAreMatched(conditions, { name: "Hi World" })).toEqual(false); | ||
}); | ||
it("should match with operator: endsWith", function () { | ||
const conditions: Condition[] = [ | ||
{ | ||
attribute: "name", | ||
operator: "endsWith", | ||
value: "World", | ||
}, | ||
]; | ||
// match | ||
expect(allConditionsAreMatched(conditions, { name: "Hello World" })).toEqual(true); | ||
expect(allConditionsAreMatched(conditions, { name: "Hi World" })).toEqual(true); | ||
// not match | ||
expect(allConditionsAreMatched(conditions, { name: "Hi Universe" })).toEqual(false); | ||
}); | ||
it("should match with operator: contains", function () { | ||
const conditions: Condition[] = [ | ||
{ | ||
attribute: "name", | ||
operator: "contains", | ||
value: "Hello", | ||
}, | ||
]; | ||
// match | ||
expect(allConditionsAreMatched(conditions, { name: "Hello World" })).toEqual(true); | ||
expect(allConditionsAreMatched(conditions, { name: "Yo! Hello!" })).toEqual(true); | ||
// not match | ||
expect(allConditionsAreMatched(conditions, { name: "Hi World" })).toEqual(false); | ||
}); | ||
it("should match with operator: notContains", function () { | ||
const conditions: Condition[] = [ | ||
{ | ||
attribute: "name", | ||
operator: "notContains", | ||
value: "Hello", | ||
}, | ||
]; | ||
// match | ||
expect(allConditionsAreMatched(conditions, { name: "Hi World" })).toEqual(true); | ||
// not match | ||
expect(allConditionsAreMatched(conditions, { name: "Hello World" })).toEqual(false); | ||
expect(allConditionsAreMatched(conditions, { name: "Yo! Hello!" })).toEqual(false); | ||
}); | ||
it("should match with operator: in", function () { | ||
const conditions: Condition[] = [ | ||
{ | ||
attribute: "browser_type", | ||
operator: "in", | ||
value: ["chrome", "firefox"], | ||
}, | ||
]; | ||
// match | ||
expect(allConditionsAreMatched(conditions, { browser_type: "chrome" })).toEqual(true); | ||
expect(allConditionsAreMatched(conditions, { browser_type: "firefox" })).toEqual(true); | ||
// not match | ||
expect(allConditionsAreMatched(conditions, { browser_type: "edge" })).toEqual(false); | ||
expect(allConditionsAreMatched(conditions, { browser_type: "safari" })).toEqual(false); | ||
}); | ||
it("should match with operator: notIn", function () { | ||
const conditions: Condition[] = [ | ||
{ | ||
attribute: "browser_type", | ||
operator: "notIn", | ||
value: ["chrome", "firefox"], | ||
}, | ||
]; | ||
// match | ||
expect(allConditionsAreMatched(conditions, { browser_type: "edge" })).toEqual(true); | ||
expect(allConditionsAreMatched(conditions, { browser_type: "safari" })).toEqual(true); | ||
// not match | ||
expect(allConditionsAreMatched(conditions, { browser_type: "chrome" })).toEqual(false); | ||
expect(allConditionsAreMatched(conditions, { browser_type: "firefox" })).toEqual(false); | ||
}); | ||
it("should match with operator: greaterThan", function () { | ||
@@ -59,2 +163,20 @@ const conditions: Condition[] = [ | ||
it("should match with operator: greaterThanOrEquals", function () { | ||
const conditions: Condition[] = [ | ||
{ | ||
attribute: "age", | ||
operator: "greaterThanOrEquals", | ||
value: 18, | ||
}, | ||
]; | ||
// match | ||
expect(allConditionsAreMatched(conditions, { age: 18 })).toEqual(true); | ||
expect(allConditionsAreMatched(conditions, { age: 19 })).toEqual(true); | ||
// not match | ||
expect(allConditionsAreMatched(conditions, { age: 17 })).toEqual(false); | ||
expect(allConditionsAreMatched(conditions, { age: 16 })).toEqual(false); | ||
}); | ||
it("should match with operator: lessThan", function () { | ||
@@ -76,2 +198,20 @@ const conditions: Condition[] = [ | ||
it("should match with operator: lessThanOrEquals", function () { | ||
const conditions: Condition[] = [ | ||
{ | ||
attribute: "age", | ||
operator: "lessThanOrEquals", | ||
value: 18, | ||
}, | ||
]; | ||
// match | ||
expect(allConditionsAreMatched(conditions, { age: 17 })).toEqual(true); | ||
expect(allConditionsAreMatched(conditions, { age: 18 })).toEqual(true); | ||
// not match | ||
expect(allConditionsAreMatched(conditions, { age: 19 })).toEqual(false); | ||
expect(allConditionsAreMatched(conditions, { age: 20 })).toEqual(false); | ||
}); | ||
it("should match with operator: semverEquals", function () { | ||
@@ -78,0 +218,0 @@ const conditions: Condition[] = [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
814078
5683