How to use the equal function from assert
Find comprehensive JavaScript assert.equal code examples handpicked from public code repositorys.
24 25 26 27 28 29 30 31 32 33 34
* @param {number} time1 * @param {number} time2 * @param {string} [message] for assertion */ assertTimesInSync(time1, time2, message = '') { assert.equal(Math.abs(time1 - time2) < TIME_DIFF_THRESHOLD, true, message); } } module.exports = AssertionHelper;
215
308
0
184 185 186 187 188 189 190 191 192 193
sinon.assert.calledWith(captureStream, 0); delete global.CanvasCaptureMediaStreamTrack; }); it('should add a VideoProcessor', () => { assert.equal(videoTrack.processor, processor); }); it('should not log a warning', () => { sinon.assert.notCalled(log.warn);
208
537
83
+ 18 other calls in file
GitHub: dependents/node-precinct
298 299 300 301 302 303 304 305 306 307
const cjs = precinct(read('cjsExportLazy.js')); assert.equal(cjs[0], './amd'); assert.equal(cjs[1], './es6'); assert.equal(cjs[2], './es7'); assert.equal(cjs.length, 3); }); }); describe('when a main require is used', () => {
39
177
0
+ 89 other calls in file
38 39 40 41 42 43 44 45 46
assert.notEqual(stateChange, null); assert.equal(stateChange.context.properties.length, 1); assert.equal(stateChange.context.properties[0].name, 'brightness'); assert.equal(stateChange.event.payload.change.properties[0].name, 'powerState'); assert.equal(stateChange.event.payload.change.cause.type, 'VOICE_INTERACTION'); }) it('on physical interaction', async function () {
21
65
0
+ 11 other calls in file
37 38 39 40 41 42 43 44 45 46
const event = await helpers.getSample('StateReport/ReportState.json') const response = await lightDeviceManager.handleAlexaEvent(event); assert.equal(response.event.header.namespace, "Alexa", "Namespace!"); assert.equal(response.event.header.name, "StateReport", "Name!"); assert.equal(response.event.header.correlationToken, event.directive.header.correlationToken, "Name!"); assert.equal(response.event.endpoint.endpointId, endpointId, "Endpoint Id!"); assert.equal(response.context.properties.length, 1); assert.equal(response.context.properties[0].namespace, "Alexa.PowerController");
21
65
0
+ 27 other calls in file
361 362 363 364 365 366 367 368 369 370 371 372
} assert.ok = ok; // 5. The equality assertion tests shallow, coercive equality with // ==. // assert.equal(actual, expected, message_opt); assert.equal = function equal(actual, expected, message) { if (actual != expected) fail(actual, expected, message, '==', assert.equal); };
11
21
6
+ 3 other calls in file
5 6 7 8 9 10 11 12 13 14 15
describe("Metrics service", () => { beforeEach(() => test.clear()); it("retrieves memory details", async () => { const res = await request(terminal).get("/metrics").send(); equal(res.status, 200); notEqual(res.body.free, undefined); notEqual(res.body.total, undefined); }); });
7
448
9
14 15 16 17 18 19 20 21 22 23
describe("in declarative mode", () => { const details = { declarative: true, details: true }; it("runs statements in the state", () => { nucleoid.run("var i = 1 ;"); equal(nucleoid.run("i == 1"), true); }); it("runs expression statement", () => { nucleoid.run("var j = 1 ;");
7
448
9
+ 573 other calls in file
883 884 885 886 887 888 889 890 891 892
assert.deepStrictEqual( operations(actual), operations(expected), "Operations" ); assert.equal( actual.paths["/fun()"].get.summary, "no parameters", "function summary" );
70
160
20
+ 14 other calls in file
GitHub: NucleoidJS/Nucleoid
14 15 16 17 18 19 20 21 22 23
await request(terminal).post("/").send("'Hello'"); const res2 = await request(terminal).get("/logs").send(); const logs2 = res2.body; equal(res2.status, 200); equal(logs2.length, 1); equal(logs2[0].s, "'Hello'"); notEqual(logs2[0].t, undefined); equal(logs2[0].r, "Hello");
7
448
9
+ 11 other calls in file
116 117 118 119 120 121 122 123 124 125
describe('GET sample resources', function () { sampleResources.forEach(function (spec) { it(`Resource ${spec.id} has correct type ${spec.type}`, function (done) { request.get(`${global.TEST_BASE_URL}/api/v0.1/discovery/resources/${spec.id}`, function (err, response, body) { if (err) throw err assert.equal(200, response.statusCode) var doc = JSON.parse(body) assert(doc['@type'].indexOf(spec.type) >= 0) done() })
0
6
4
+ 33 other calls in file
GitHub: surveyjs/survey-library
50 51 52 53 54 55 56 57 58 59
); test("click on question title state editable", async (t) => { var newTitle = "MyText"; var json = JSON.parse(await getQuestionJson()); assert.equal(await getQuestionValue(), null); var outerSelector = ".sv_q_title"; var innerSelector = ".sv-string-editor"; await t
712
0
73
+ 32 other calls in file
5 6 7 8 9 10 11 12 13 14
describe('integer()', function() { it('should return value when the value is present', function() { var my_validator = new FieldVal({ "my_value": 13 }) assert.equal(13, my_validator.get("my_value", bval.integer(true))); assert.strictEqual(null, my_validator.end()); }) it('should not continue if required=false and the value is missing', function(){
9
137
4
+ 159 other calls in file
1023 1024 1025 1026 1027 1028 1029 1030 1031 1032
// This print can be very helpful for debugging the expect vs receive vals if (consoleOptions.expectedActual) { console.log(`\t${property.name} => [ expected: ${value} ] [ actual: ${result[property.name]} ]`); } if (typeof value === 'number') { assert.equal(result[property.name], value, `${property.name} value of ${result[property.name]} does not match expected value ${value}`); } else if (typeof value === 'object' && !Array.isArray(value)) { Object.entries(value).forEach(([key, deepValue]) => {
57
140
51
16 17 18 19 20 21 22 23 24 25
"my_date_8": "29/02/2004", "my_date_9": "29/05/2014 15:45:12", }) assert.equal("04/07/2014", my_validator.get("my_date_1", BasicVal.string(true), BasicVal.date("dd/MM/yyyy"))); assert.equal("1/2/34", my_validator.get("my_date_2", BasicVal.string(true), BasicVal.date("d/M/yy"))); assert.equal("1-2-34", my_validator.get("my_date_3", BasicVal.string(true), BasicVal.date("d-M-yy"))); assert.equal("29:2", my_validator.get("my_date_4", BasicVal.string(true), BasicVal.date("d:M"))); assert.equal("2014 05 27", my_validator.get("my_date_5", BasicVal.string(true), BasicVal.date("yyyy MM dd"))); assert.equal("07/30/14", my_validator.get("my_date_6", BasicVal.string(true), BasicVal.date("MM/dd/yy")));
9
137
4
+ 80 other calls in file
GitHub: algorand/js-algorand-sdk
4303 4304 4305 4306 4307 4308 4309 4310 4311 4312
); Then('calling app trace produces {string}', async function (expected) { const traceString = this.txtrace.appTrace(); const expectedString = (await loadResource(expected)).toString(); assert.equal(traceString, expectedString); }); When( 'I append to my Method objects list in the case of a non-empty signature {string}',
185
264
27
+ 4 other calls in file
155 156 157 158 159 160 161 162 163 164 165
const testBasicStorage = await newContract(TestBasicStorage); return testBasicStorage; } const resAssert = (res, gasUsed, eventName, item, value) => { assert.equal(Math.abs(Number(res.gasUsed) - Number(gasUsed)) < 200000, true, "Gas used not match:" + res.gasUsed.toString() + ":" + gasUsed.toString()); if (eventName) { assert.equal(res.events[eventName] != undefined, true, "Event name not found"); }
10
10
6
+ 2 other calls in file
64 65 66 67 68 69 70 71 72 73
assert.equal(derivedObj1.testProp1, 'SuperProp1'); assert.equal(derivedObj1.testProp2, 'Derived1Prop2'); assert.equal(derivedObj1.prop, undefined); assert.equal(derivedObj2.testProp1, 'SuperProp1'); assert.equal(derivedObj2.testProp2, 'Derived2Prop2'); assert.equal(derivedObj2.prop, 'xxx'); assert.equal(derivedObj3.testProp1, undefined);
0
1
1
+ 12 other calls in file
2 3 4 5 6 7 8 9 10 11 12 13
var assert = require('assert') describe('FieldVal', function() { describe('constructor', function() { it('should return an object if constructed with an empty object', function() { assert.equal('object', typeof new FieldVal({})); }) it('should return an object if constructed with a null parameter', function() { assert.equal('object', typeof new FieldVal(null));
9
137
4
+ 80 other calls in file
GitHub: porterhq/porter
106 107 108 109 110 111 112 113 114 115
}); describe('module.obtain()', function() { it('should transpile', async function() { const mod = porter.packet.files['stylesheets/app.less']; assert.equal(mod.constructor.name, 'LessModule'); const { code } = await mod.obtain(); assert.ok(!code.includes('@theme-color')); assert.ok(code.includes('#233333')); assert.ok(code.includes('.page'));
7
40
9
+ 55 other calls in file
assert.equal is the most popular function in assert (3580 examples)