Created
November 18, 2021 09:23
-
-
Save lorenzofox3/b59951caa54494dc35609f2190f5ce8f to your computer and use it in GitHub Desktop.
reporting-comparisonreporting-comparison
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import test from 'ava'; | |
import {Bar, Foo, monkeyPatched, objWithPrototype, simpleObj} from './tested.js'; | |
test(`native custom type(date)`, (t) => { | |
t.deepEqual( | |
{prop: new Date('2222-01-01T00:00:00.000Z')}, | |
{prop: '2222-01-01T00:00:00.000Z'} | |
); | |
}); | |
test(`prototypal chain (with constructor)`, (t) => { | |
t.deepEqual( | |
{prop:new Foo()}, | |
{prop:new Bar()} | |
); | |
}); | |
test(`prototypal chains`, (t) => { | |
t.deepEqual( | |
simpleObj, | |
objWithPrototype | |
); | |
}); | |
test(`configured properties`, (t) => { | |
t.deepEqual( | |
simpleObj, | |
monkeyPatched | |
); | |
}); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo { | |
constructor() { | |
this.prop = 'value'; | |
} | |
} | |
class Bar { | |
constructor() { | |
this.prop = 'value'; | |
} | |
} | |
const simpleObj = Object.defineProperties({}, { | |
prop: {value: 'value'} | |
}); | |
const monkeyPatched = Object.defineProperties({}, { | |
prop: {value: 'value', enumerable: true} | |
}); | |
test(`native custom type(date)`, () => { | |
expect({prop: new Date('2222-01-01T00:00:00.000Z')}) | |
.toEqual({prop: '2222-01-01T00:00:00.000Z'}); | |
}); | |
test(`prototypal chain (with constructor)`, () => { | |
expect(new Foo()).toEqual(new Bar()); | |
}); | |
test(`prototypal chain`, () => { | |
expect(simpleObj).toEqual(monkeyPatched); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {deepStrictEqual} from 'assert'; | |
import {Bar, Foo, monkeyPatched, objWithPrototype, simpleObj} from './tested.js'; | |
describe('weird similar but different objects', () => { | |
it(`native custom type(date)`, () => { | |
deepStrictEqual( | |
{prop: new Date('2222-01-01T00:00:00.000Z')}, | |
{prop: '2222-01-01T00:00:00.000Z'} | |
); | |
}); | |
it(`prototypal chain (with constructor)`, () => { | |
// deepStrictEqual( | |
// new Foo(), | |
// new Bar() | |
// ); | |
deepStrictEqual( | |
{prop:new Foo()}, | |
{prop:new Bar()} | |
); | |
}); | |
it(`prototypal chain`, () => { | |
deepStrictEqual( | |
simpleObj, | |
objWithPrototype | |
); | |
}); | |
it(`configured props`, () => { | |
deepStrictEqual( | |
simpleObj, | |
monkeyPatched | |
); | |
}); | |
}); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "test-diff-comp", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"type": "module", | |
"scripts": { | |
"test:zora": "pta pta.js", | |
"test:ava": "ava", | |
"test:jest": "jest jest", | |
"test:mocha": "mocha mocha.js" | |
}, | |
"ava": { | |
"files": ["ava.js"] | |
}, | |
"author": "", | |
"license": "ISC", | |
"devDependencies": { | |
"ava": "~3.15.0", | |
"jest": "~27.3.1", | |
"mocha": "~9.1.3", | |
"pta": "~1.0.0" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {test} from 'zora'; | |
import {Bar, Foo, monkeyPatched, objWithPrototype, simpleObj} from './tested.js'; | |
test(`native custom type(date)`, (t) => { | |
t.eq( | |
{prop: new Date('2222-01-01T00:00:00.000Z')}, | |
{prop: '2222-01-01T00:00:00.000Z'} | |
); | |
}); | |
test(`prototypal chain (with constructor)`, (t) => { | |
t.eq( | |
new Foo(), | |
new Bar() | |
); | |
}); | |
test(`prototypal chain`, (t) => { | |
t.eq( | |
simpleObj, | |
objWithPrototype | |
); | |
}); | |
test(`configured props`, (t) => { | |
t.eq( | |
simpleObj, | |
monkeyPatched | |
); | |
}); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class Foo { | |
constructor() { | |
this.prop = 'value'; | |
} | |
} | |
export class Bar { | |
constructor() { | |
this.prop = 'value'; | |
} | |
} | |
export const simpleObj = Object.defineProperties({}, { | |
prop: {value: 'value'} | |
}); | |
export const objWithPrototype = Object.create({ | |
behaviorMethod(){} | |
},{ | |
prop: {value: 'value'} | |
}) | |
export const monkeyPatched = Object.defineProperties({}, { | |
prop: {value: 'value', enumerable: true} | |
}) | |
; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment