2023-09-20 01:18:01 -07:00
|
|
|
import { createRequire } from 'node:module'
|
|
|
|
|
2022-08-06 21:54:58 +08:00
|
|
|
import test from 'ava'
|
|
|
|
|
2023-09-20 01:18:01 -07:00
|
|
|
const require = createRequire(import.meta.url)
|
|
|
|
|
|
|
|
const {
|
|
|
|
NotWritableClass,
|
|
|
|
}: typeof import('../index.js') = require('../index.node')
|
2022-08-06 21:54:58 +08:00
|
|
|
|
|
|
|
test('Not Writable Class', (t) => {
|
|
|
|
const obj = new NotWritableClass('1')
|
|
|
|
t.throws(() => {
|
|
|
|
obj.name = '2'
|
|
|
|
})
|
|
|
|
obj.setName('2')
|
|
|
|
t.is(obj.name, '2')
|
|
|
|
t.throws(() => {
|
|
|
|
obj.setName = () => {}
|
|
|
|
})
|
|
|
|
})
|