Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge w/ origin #1

Merged
merged 8 commits into from
Oct 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs-src/rx-collection.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ myDatabase.collection({
```

### name
The name uniquely identifies the collection and should be used to refind the collection in the database. Two different collections in the same database can never have the same name.
The name uniquely identifies the collection and should be used to refind the collection in the database. Two different collections in the same database can never have the same name. Collection names must match the following regex: `^[a-z][a-z0-9]*$`.

### schema
The schema defines how your data looks and how it should be handled. You can pass a RxSchema-Object or a simple javascript-object from which the schema will be generated.
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
"delete": "1.1.0",
"detect-browser": "2.0.0",
"disc": "1.3.3",
"eslint": "4.8.0",
"eslint": "4.9.0",
"eslint-plugin-babel": "4.1.2",
"eslint-plugin-disable": "0.3.0",
"eslint-plugin-spellcheck": "0.0.8",
Expand Down Expand Up @@ -153,11 +153,12 @@
"rimraf": "2.6.2",
"rxjs": "5.4.3",
"shelljs": "0.7.8",
"ts-node": "^3.3.0",
"typescript": "2.5.3",
"uglify-js": "3.1.3",
"walk-sync": "0.3.2",
"watch": "1.0.2",
"watchify": "3.9.0",
"webpack": "3.6.0"
"webpack": "3.7.0"
}
}
1 change: 1 addition & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ interface JsonSchema {
format?: "date-time" | "email" | "hostname" | "ipv4" | "ipv6" | "uri" | string;
ref?: string;
primary?: boolean;
index?: boolean;
final?: boolean;
}

Expand Down
3 changes: 2 additions & 1 deletion test/unit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ const nodeAndBrowser = [
];

const nodeOnly = [
'../test_tmp/unit/plugin.test.js'
'../test_tmp/unit/plugin.test.js',
'../test_tmp/unit/typings.test.js'
];

module.exports = {
Expand Down
72 changes: 72 additions & 0 deletions test/unit/typings.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/**
* this checks if typings work as expected
*/
import assert from 'assert';
import * as schemas from './../helper/schemas';

describe('typings.test.js', () => {
const codeBase = `
import {create, RxDatabase, RxCollection, SchemaJSON} from '../';
`;
const transpileCode = async(code) => {
const spawn = require('child-process-promise').spawn;
const stdout = [];
const stderr = [];
const promise = spawn('ts-node', [
'--compilerOptions', '{"target":"es6"}',
'-p', code
]);
const childProcess = promise.childProcess;
childProcess.stdout.on('data', data => stdout.push(data.toString()));
childProcess.stderr.on('data', data => stderr.push(data.toString()));
try {
await promise;
} catch (err) {
throw new Error(`could not run
# Error: ${err}
# Output: ${stdout}
# ErrOut: ${stderr}
`);
}
};

describe('basic', () => {
it('should sucess on basic test', async() => {
await transpileCode('console.log("Hello, world!")');
});
it('should fail on broken code', async() => {
const brokenCode = `
let x: string = 'foo';
x = 1337;
`;
let thrown = false;
try {
await transpileCode(brokenCode);
} catch (err) {
thrown = true;
}
assert.ok(thrown);
});
});
describe('positive', () => {
it('collection-creation', async() => {
const code = codeBase + `
(async() => {
const myDb: RxDatabase = await create({
name: 'mydb',
adapter: 'memory',
multiInstance: false,
ignoreDuplicate: false
});
const mySchema: SchemaJSON = ${JSON.stringify(schemas.human)};
const myCollection: RxCollection<any> = await myDb.collection({
name: 'humans',
schema: mySchema,
autoMigrate: false
});
})();
`;
await transpileCode(code);
});
});
});