-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
114 additions
and
1 deletion.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { suite } from 'uvu'; | ||
import * as assert from 'assert'; | ||
|
||
export default function (klona) { | ||
const Descriptors = suite('Descriptor'); | ||
|
||
Descriptors('hidden', () => { | ||
const input = { foo: 123 }; | ||
Object.defineProperty(input, 'bar', { | ||
enumerable: false, | ||
value: [1, 2, 3] | ||
}); | ||
|
||
const output = klona(input); | ||
assert.deepEqual(input, output); | ||
|
||
assert.deepEqual( | ||
Object.getOwnPropertyDescriptor(output, 'bar'), | ||
{ | ||
enumerable: false, | ||
configurable: false, | ||
writable: false, | ||
value: [1, 2, 3] | ||
} | ||
); | ||
|
||
output.bar.push('howdy'); | ||
assert.deepEqual(input.bar, [1, 2, 3]); | ||
}); | ||
|
||
Descriptors('hidden writable configurable', () => { | ||
const input = { foo: 123 }; | ||
Object.defineProperty(input, 'bar', { | ||
enumerable: false, | ||
configurable: true, | ||
writable: true, | ||
value: [1, 2, 3] | ||
}); | ||
|
||
const output = klona(input); | ||
assert.deepEqual(input, output); | ||
|
||
assert.deepEqual( | ||
Object.getOwnPropertyDescriptor(output, 'bar'), | ||
{ | ||
enumerable: false, | ||
configurable: true, | ||
writable: true, | ||
value: [1, 2, 3] | ||
} | ||
); | ||
|
||
output.bar.push('howdy'); | ||
assert.deepEqual(input.bar, [1, 2, 3]); | ||
}); | ||
|
||
Descriptors('hidden getter', () => { | ||
const input = { foo: 123 }; | ||
Object.defineProperty(input, 'bar', { | ||
enumerable: false, | ||
get() { | ||
return [1, 2, 3] | ||
} | ||
}); | ||
|
||
const output = klona(input); | ||
assert.deepEqual(input, output); | ||
|
||
const xyz = Object.getOwnPropertyDescriptor(output, 'bar'); | ||
assert.equal(typeof xyz.get, 'function'); | ||
|
||
output.bar.push('howdy'); | ||
assert.deepEqual(input.bar, [1, 2, 3]); | ||
assert.deepEqual(output.bar, [1, 2, 3]); | ||
}); | ||
|
||
Descriptors.run(); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { suite } from 'uvu'; | ||
import * as assert from 'assert'; | ||
|
||
export default function (klona) { | ||
const Dictionarys = suite('Dictionary'); | ||
|
||
Dictionarys('dictionary :: empty', () => { | ||
const input = Object.create(null); | ||
|
||
let output = klona(input); | ||
assert.deepEqual(input, output); | ||
assert.equal(output.constructor, undefined); | ||
|
||
output.foo = 123; | ||
assert.equal(input.foo, undefined); | ||
}); | ||
|
||
Dictionarys('dictionary :: values', () => { | ||
const input = Object.create(null); | ||
input.hello = 'world'; | ||
input.list = [1, 2, 3]; | ||
|
||
let output = klona(input); | ||
assert.deepEqual(input, output); | ||
assert.equal(output.constructor, undefined); | ||
|
||
output.list.push('howdy'); | ||
assert.deepEqual(input.list, [1, 2, 3]); | ||
}); | ||
|
||
Dictionarys.run(); | ||
} |
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