Initial import with skill sheet working

This commit is contained in:
2024-12-04 00:11:23 +01:00
commit 9050c80ab4
4488 changed files with 671048 additions and 0 deletions

29
node_modules/nedb-promises/test/a.create.test.js generated vendored Normal file
View File

@ -0,0 +1,29 @@
const fs = require('fs');
const Datastore = require('../src/Datastore');
describe('testing datastore creation', () => {
describe('new Datastore(\'foo.db\')', () => {
it('should create foo.db based on string filename', async () => {
const datastore = Datastore.create('foo.db');
await datastore.load();
expect(fs.existsSync('foo.db')).toBe(true);
fs.unlinkSync('foo.db');
});
});
describe('new Datastore({ filename: \'bar.db\' })', () => {
it('sould create bar.db based on object parameters', async () => {
const datastore = Datastore.create({ filename: 'bar.db' });
await datastore.load();
expect(fs.existsSync('bar.db')).toBe(true);
fs.unlinkSync('bar.db');
});
});
describe('new Datastore()', () => {
it('should create in memory only database', () => {
const datastore = Datastore.create();
expect(datastore.inMemoryOnly).toBe(true);
});
});
});

27
node_modules/nedb-promises/test/b.insert.test.js generated vendored Normal file
View File

@ -0,0 +1,27 @@
const Datastore = require('../src/Datastore');
describe('testing document insertion', () => {
const docs = [
{ name: '1st document' },
{ name: '2nd document' },
{ name: '3rd document' },
];
describe('single', () => {
it('should insert single document', async () => {
const datastore = Datastore.create();
const insertedDoc = await datastore.insert(docs[0]);
expect(insertedDoc).toMatchObject({ name: '1st document' });
expect(insertedDoc).toHaveProperty('_id');
});
});
describe('bulk', () => {
it('should insert multiple documents', async () => {
const datastore = Datastore.create();
const insertedDocs = await datastore.insert(docs);
expect(insertedDocs.length).toBe(3);
expect(insertedDocs).toMatchObject(docs);
});
});
});

43
node_modules/nedb-promises/test/c.find.test.js generated vendored Normal file
View File

@ -0,0 +1,43 @@
const Datastore = require('../src/Datastore');
describe('testing document finding', () => {
const docs = [
{ name: '1st document' },
{ name: '2nd document' },
{ name: '3rd document' },
];
const datastore = Datastore.create();
beforeEach(() => datastore.insert(docs));
afterEach(() => datastore.remove({}, { multi: true }));
describe('single', () => {
it('should find the first inserted doc', async () => {
const foundDoc = await datastore.findOne();
expect(foundDoc).toHaveProperty('_id');
expect(foundDoc).toHaveProperty('name');
expect(foundDoc.name).toMatch(/^(1st|2nd|3rd) document$/);
});
it('should find the last inserted doc when sorting backwards', async () => {
const foundDoc = await datastore.findOne().sort({ name: -1 });
expect(foundDoc).toHaveProperty('_id');
expect(foundDoc).toHaveProperty('name');
expect(foundDoc.name).toBe('3rd document');
});
});
describe('bulk', () => {
it('should find all inserted docs', async () => {
const foundDocs = await datastore.find().sort({ name: 1 }).exec();
expect(foundDocs).toMatchObject(docs);
});
});
describe('find().then()', () => {
it('should find all inserted docs', async () => {
const foundDocs = await datastore.find().sort({ name: 1 });
expect(foundDocs).toMatchObject(docs);
});
});
});

70
node_modules/nedb-promises/test/d.update.test.js generated vendored Normal file
View File

@ -0,0 +1,70 @@
const Datastore = require('../src/Datastore');
describe('testing document update', () => {
const docs = [
{ name: '1st document' },
{ name: '2nd document' },
{ name: '3rd document' },
];
const datastore = Datastore.create();
beforeEach(() => datastore.insert(docs));
afterEach(() => datastore.remove({}, { multi: true }));
describe('single', () => {
it('should update single document', async () => {
const { _id } = await datastore.findOne({ name: /^1st/ });
const numAffected = await datastore.update({ name: /^1st/ }, { test: true }, { multi: false });
expect(numAffected).toBe(1);
const affectedDoc = await datastore.findOne({ test: true });
expect(affectedDoc).toMatchObject({ _id, test: true });
});
});
describe('single with returnUpdatedDocs', () => {
it('should update and return single document', async () => {
const { _id } = await datastore.findOne({ name: /^1st/ });
const affectedDoc = await datastore.update(
{ name: '1st document' },
{ test: true },
{ multi: false, returnUpdatedDocs: true },
);
expect(affectedDoc).toMatchObject({ _id, test: true });
});
});
describe('bulk', () => {
it('should update multiple documents', async () => {
const numAffected = await datastore.update(
{ name: { $regex: /^1st|2nd/ } },
{ $set: { test: true } },
{ multi: true },
);
expect(numAffected).toBe(2);
const affectedDocs = await datastore.find({ test: true });
expect(affectedDocs.length).toBe(2);
affectedDocs.forEach((affectedDoc) => {
expect(affectedDoc.name.match(/^1st|2nd/)).toBeTruthy();
expect(affectedDoc.test).toBe(true);
});
});
});
describe('bulk with returnUpdatedDocs', () => {
it('should update and return multiple documents', async () => {
const affectedDocs = await datastore.update(
{ name: { $regex: /^2nd|3rd/ } },
{ $set: { test: true } },
{ multi: true, returnUpdatedDocs: true },
);
expect(affectedDocs.length).toBe(2);
affectedDocs.forEach((affectedDoc) => {
expect(affectedDoc.name.match(/^2nd|3rd/)).toBeTruthy();
expect(affectedDoc.test).toBe(true);
});
});
});
});

25
node_modules/nedb-promises/test/e.count.test.js generated vendored Normal file
View File

@ -0,0 +1,25 @@
const Datastore = require('../src/Datastore');
describe('testing document counting', () => {
const docs = [
{ name: '1st document' },
{ name: '2nd document' },
{ name: '3rd document' },
];
const datastore = Datastore.create();
beforeEach(() => datastore.insert(docs));
afterEach(() => datastore.remove({}, { multi: true }));
describe('count', () => {
it('should get the count of the docs', async () => {
const count = await datastore.count();
expect(count).toBe(3);
});
it('should get the count of the docs when limiting', async () => {
const count = await datastore.count().limit(2);
expect(count).toBe(2);
});
});
});

16
node_modules/nedb-promises/test/f.proxy.test.js generated vendored Normal file
View File

@ -0,0 +1,16 @@
const Cursor = require('../src/Cursor');
const Datastore = require('../src/Datastore');
const Persistence = require('@seald-io/nedb/lib/persistence');
describe('testing datastore proxy', () => {
const datastore = Datastore.create('test.db');
it('should not affect promise returns', () => {
expect(datastore.find({}) instanceof Cursor).toBe(true);
expect(datastore.insert({ proxy: true }) instanceof Promise).toBe(true);
});
it('should return original datastore values', () => {
expect(datastore.persistence instanceof Persistence).toBe(true);
});
});

62
node_modules/nedb-promises/test/g.mongocompat.test.js generated vendored Normal file
View File

@ -0,0 +1,62 @@
const Datastore = require('../src/Datastore');
describe('testing MongoDB compatibility methods', () => {
describe('insertOne', () => {
it('should insert a single document event when passed an array', async () => {
const datastore = Datastore.create();
const result = await datastore.insertOne([{ foo: true }, { bar: false }]);
expect(Array.isArray(result)).toBe(false);
expect(result['0']).toEqual({ foo: true });
expect(await datastore.count()).toBe(1);
});
});
describe('insertMany', () => {
it('should throw when passed a non-iterable value', async () => {
const datastore = Datastore.create();
expect(() => datastore.insertMany({})).toThrow();
});
it('should insert the specified documents otherwise', async () => {
const datastore = Datastore.create();
await datastore.insertMany([{}, {}]);
expect(await datastore.count()).toBe(2);
});
});
describe('updateOne', () => {
it('should update a single document', async () => {
const datastore = Datastore.create();
await datastore.insert([{}, {}]);
await datastore.updateOne({}, { $set: { foo: true } }, { multi: true });
expect(await datastore.count({ foo: true })).toBe(1);
});
});
describe('updateMany', () => {
it('should update multiple documents', async () => {
const datastore = Datastore.create();
await datastore.insert([{}, {}]);
await datastore.updateMany({}, { $set: { foo: true } }, { multi: false });
expect(await datastore.count({ foo: true })).toBe(2);
});
});
describe('deleteOne', () => {
it('should update a single document', async () => {
const datastore = Datastore.create();
await datastore.insert([{}, {}]);
await datastore.deleteOne({}, { multi: true });
expect(await datastore.count()).toBe(1);
});
});
describe('deleteMany', () => {
it('should update multiple documents', async () => {
const datastore = Datastore.create();
await datastore.insert([{}, {}]);
await datastore.deleteMany({}, { multi: false });
expect(await datastore.count()).toBe(0);
});
});
});