Skip to content

Commit

Permalink
Stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
phortx committed Apr 26, 2019
1 parent df4a696 commit 9f687c9
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 33 deletions.
4 changes: 2 additions & 2 deletions test/integration/plugin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import gql from "graphql-tag";
let store: any;
let vuexOrmGraphQL;

describe("VuexORMGraphQL", () => {
describe("Plugin GraphQL", () => {
beforeEach(async () => {
[store, vuexOrmGraphQL] = await setupMockData();
});
Expand Down Expand Up @@ -996,7 +996,7 @@ query Status {

const tariff = Tariff.query()
.withAllRecursive()
.find(1)!;
.find("ED5F2379-6A8B-4E1D-A4E3-A2C03057C2FC")!;
expect(tariff.name).toEqual("Super DSL S");
expect(tariff.tariffOptions).not.toEqual(null);
expect(tariff.tariffOptions.length).not.toEqual(0);
Expand Down
11 changes: 6 additions & 5 deletions test/support/mock-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ export class Comment extends ORMModel {
export class TariffTariffOption extends ORMModel {
static entity = "tariffTariffOptions";

static primaryKey = ["tariffId", "tariffOptionId"];
static primaryKey = ["tariffUuid", "tariffOptionId"];

static fields(): Fields {
return {
tariffId: this.number(0),
tariffUuid: this.string(""),
tariffOptionId: this.number(0)
};
}
Expand All @@ -108,10 +108,11 @@ export class TariffTariffOption extends ORMModel {
export class Tariff extends ORMModel {
static entity = "tariffs";
static eagerLoad = ["tariffOptions"];
static primaryKey = ["uuid"];

static fields(): Fields {
return {
id: this.increment(),
uuid: this.string(""),
name: this.string(""),
displayName: this.string(""),
tariffType: this.string(""),
Expand All @@ -120,7 +121,7 @@ export class Tariff extends ORMModel {
tariffOptions: this.belongsToMany(
TariffOption,
TariffTariffOption,
"tariffId",
"tariffUuid",
"tariffOptionId"
)
};
Expand All @@ -137,7 +138,7 @@ export class TariffOption extends ORMModel {
name: this.string(""),
description: this.string(""),

tariffs: this.belongsToMany(Tariff, TariffTariffOption, "tariffOptionId", "tariffId")
tariffs: this.belongsToMany(Tariff, TariffTariffOption, "tariffOptionId", "tariffUuid")
};
}
}
Expand Down
24 changes: 12 additions & 12 deletions test/support/mock-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const typeDefs = `
comments(filter: CommentFilter): CommentTypeConnection!
tariffOption(id: ID!): TariffOption!
tariffOptions(filter: TariffOptionFilter): TariffOptionTypeConnection!
tariff(id: ID!): Tariff!
tariff(uuid: String!): Tariff!
tariffs(filter: TariffFilter): TariffTypeConnection!
tariffTariffOption(id: ID!): TariffTariffOption!
tariffTariffOptions(filter: TariffTariffOptionFilter): TariffTariffOptionTypeConnection!
Expand All @@ -46,7 +46,7 @@ export const typeDefs = `
deleteVideo(id: ID!): Video!
deleteComment(id: ID!): Comment!
deleteTariffOption(id: ID!): TariffOption!
deleteTariff(id: ID!): Tariff!
deleteTariff(uuid: String!): Tariff!
createUser(user: UserInput!): User!
createProfile(profile: ProfileInput!): Profile!
Expand All @@ -62,7 +62,7 @@ export const typeDefs = `
updateVideo(id: ID!, video: VideoInput!): Video!
updateComment(id: ID!, comment: CommentInput!): Comment!
updateTariffOption(id: ID!, tariffOption: TariffOptionInput!): TariffOption!
updateTariff(id: ID!, tariff: TariffInput!): Tariff!
updateTariff(uuid: String!, tariff: TariffInput!): Tariff!
upvotePost(captchaToken: String!, id: ID!): Post!
sendSms(to: String!, text: String!): SmsStatus!
Expand Down Expand Up @@ -282,7 +282,7 @@ export const typeDefs = `
type Tariff {
id: ID
uuid: String
name: String!
displayName: String
tariffType: String
Expand All @@ -292,7 +292,7 @@ export const typeDefs = `
input TariffFilter {
id: ID
uuid: String
name: String
displayName: String
tariffType: String
Expand All @@ -301,7 +301,7 @@ export const typeDefs = `
input TariffInput {
id: ID
uuid: String
name: String
displayName: String
tariffType: String
Expand All @@ -315,19 +315,19 @@ export const typeDefs = `
type TariffTariffOption {
tariffId: ID
tariffUuid: String
tariffOptionId: ID
}
input TariffTariffOptionFilter {
tariffId: ID
tariffUuid: String
tariffOptionId: ID
}
input TariffTariffOptionInput {
tariffId: ID
tariffUuid: String
tariffOptionId: ID
}
Expand Down Expand Up @@ -526,23 +526,23 @@ const comments = [

const tariffs = [
{
id: 1,
uuid: "ED5F2379-6A8B-4E1D-A4E3-A2C03057C2FC",
name: "Super DSL S",
displayName: "super-dsl-s",
tariffType: "dsl",
slug: "1as8d8w6iu"
},

{
id: 2,
uuid: "0D32575B-B15A-4949-95A0-73E6BDD75F8F",
name: "Super DSL M",
displayName: "super-dsl-m",
tariffType: "dsl",
slug: "asd8e2c89"
},

{
id: 3,
uuid: "8E54BEB8-05F3-48A7-A917-405A13865B89",
name: "Super DSL L",
displayName: "super-dsl-l",
tariffType: "dsl",
Expand Down
28 changes: 14 additions & 14 deletions test/unit/transformer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe("Transformer", () => {
tariffs: {
nodes: [
{
id: "1",
uuid: "210306B3-3008-4B91-88E0-8ED1024F5F83",
name: "Tariff S",
displayName: "Tariff S",
slug: "tariff-s",
Expand All @@ -65,7 +65,7 @@ describe("Transformer", () => {
}
},
{
id: "2",
uuid: "3F8EC67A-314D-413F-996F-87CB9A28A56C",
name: "Tariff M",
displayName: "Tariff M",
slug: "tariff-m",
Expand All @@ -81,7 +81,7 @@ describe("Transformer", () => {
}
},
{
id: "3",
uuid: "DDDB5333-DCD7-40AF-A863-DD0E9249155A",
name: "Tariff L",
displayName: "Tariff L",
slug: "tariff-l",
Expand Down Expand Up @@ -113,7 +113,7 @@ describe("Transformer", () => {
}
],
displayName: "Tariff S",
id: 1,
uuid: "210306B3-3008-4B91-88E0-8ED1024F5F83",
name: "Tariff S",
slug: "tariff-s"
},
Expand All @@ -129,7 +129,7 @@ describe("Transformer", () => {
}
],
displayName: "Tariff M",
id: 2,
uuid: "3F8EC67A-314D-413F-996F-87CB9A28A56C",
name: "Tariff M",
slug: "tariff-m"
},
Expand All @@ -145,7 +145,7 @@ describe("Transformer", () => {
}
],
displayName: "Tariff L",
id: 3,
uuid: "DDDB5333-DCD7-40AF-A863-DD0E9249155A",
name: "Tariff L",
slug: "tariff-l"
}
Expand Down Expand Up @@ -224,7 +224,7 @@ describe("Transformer", () => {
test("transforms incoming data after a mutation into a Vuex-ORM readable structure", () => {
const incomingData = {
createTariff: {
id: "1",
uuid: "210306B3-3008-4B91-88E0-8ED1024F5F83",
name: "Tariff S",
displayName: "Tariff S",
slug: "tariff-s",
Expand All @@ -251,7 +251,7 @@ describe("Transformer", () => {
}
],
displayName: "Tariff S",
id: 1,
uuid: "210306B3-3008-4B91-88E0-8ED1024F5F83",
name: "Tariff S",
slug: "tariff-s"
}
Expand All @@ -269,7 +269,7 @@ describe("Transformer", () => {
edges: [
{
node: {
id: "1",
uuid: "210306B3-3008-4B91-88E0-8ED1024F5F83",
name: "Tariff S",
displayName: "Tariff S",
slug: "tariff-s",
Expand All @@ -289,7 +289,7 @@ describe("Transformer", () => {
},
{
node: {
id: "2",
uuid: "3F8EC67A-314D-413F-996F-87CB9A28A56C",
name: "Tariff M",
displayName: "Tariff M",
slug: "tariff-m",
Expand All @@ -309,7 +309,7 @@ describe("Transformer", () => {
},
{
node: {
id: "3",
uuid: "DDDB5333-DCD7-40AF-A863-DD0E9249155A",
name: "Tariff L",
displayName: "Tariff L",
slug: "tariff-l",
Expand Down Expand Up @@ -344,7 +344,7 @@ describe("Transformer", () => {
}
],
displayName: "Tariff S",
id: 1,
uuid: "210306B3-3008-4B91-88E0-8ED1024F5F83",
name: "Tariff S",
slug: "tariff-s"
},
Expand All @@ -360,7 +360,7 @@ describe("Transformer", () => {
}
],
displayName: "Tariff M",
id: 2,
uuid: "3F8EC67A-314D-413F-996F-87CB9A28A56C",
name: "Tariff M",
slug: "tariff-m"
},
Expand All @@ -376,7 +376,7 @@ describe("Transformer", () => {
}
],
displayName: "Tariff L",
id: 3,
uuid: "DDDB5333-DCD7-40AF-A863-DD0E9249155A",
name: "Tariff L",
slug: "tariff-l"
}
Expand Down

0 comments on commit 9f687c9

Please sign in to comment.