-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
8 changed files
with
72 additions
and
21 deletions.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
This file was deleted.
Oops, something went wrong.
52 changes: 52 additions & 0 deletions
52
tests/ember-data__graph/tests/integration/resource/has-none-test.ts
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,52 @@ | ||
import type { Graph } from '@ember-data/graph/-private'; | ||
import { graphFor } from '@ember-data/graph/-private'; | ||
import Store from '@ember-data/store'; | ||
import { module, test as _test } from '@warp-drive/diagnostic'; | ||
import type { TestContext } from '@warp-drive/diagnostic/ember'; | ||
import { registerDerivations, SchemaService, withDefaults } from '@warp-drive/schema-record/schema'; | ||
|
||
interface LocalTestContext extends TestContext { | ||
store: TestStore; | ||
graph: Graph; | ||
} | ||
|
||
type DiagnosticTest = Parameters<typeof _test<LocalTestContext>>[1]; | ||
function test(name: string, callback: DiagnosticTest): void { | ||
return _test<LocalTestContext>(name, callback); | ||
} | ||
|
||
class TestStore extends Store { | ||
createSchemaService() { | ||
const schema = new SchemaService(); | ||
registerDerivations(schema); | ||
return schema; | ||
} | ||
} | ||
|
||
module<LocalTestContext>('Integration | Graph | Resource > has-none', function (hooks) { | ||
hooks.beforeEach(function () { | ||
this.store = new TestStore(); | ||
this.graph = graphFor(this.store._instanceCache._storeWrapper); | ||
}); | ||
|
||
test('Graph.getDefinition works as expected', function (assert) { | ||
const { store, graph } = this; | ||
|
||
// create a schema for a has-none relationship | ||
const UserSchema = withDefaults({ | ||
type: 'user', | ||
fields: [ | ||
{ | ||
name: 'bestFriend', | ||
kind: 'resource', | ||
type: 'user', | ||
}, | ||
], | ||
}); | ||
store.schema.registerResource(UserSchema); | ||
|
||
// check that we can call getDefinition and get back something meaningful | ||
const userDefinition = graph.getDefinition({ type: 'user' }, 'bestFriend'); | ||
debugger; | ||
}); | ||
}); |
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