Skip to content

Commit

Permalink
example adjustment and styling on few tests
Browse files Browse the repository at this point in the history
  • Loading branch information
izelnakri committed Aug 22, 2020
1 parent 555be9f commit 368b7c7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 42 deletions.
3 changes: 0 additions & 3 deletions examples/memserver/models/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ export default class User extends Model {
static defaultAttributes = {
is_admin: false,
slug() {
console.log(this.lastName);
console.log(this.is_admin);
console.log(this.firstName);
return `${this.firstName}-${this.lastName}`;
},
};
Expand Down
72 changes: 33 additions & 39 deletions src/test/model/default-attributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ test.before(async () => {
return this.name;
}
}
static publicPhotos() {
return super.findAll({ is_public: true });
}
}
`
),
Expand Down Expand Up @@ -87,63 +84,60 @@ test.serial(

PhotoFixtures.forEach((photo) => Photo.insert(photo));

t.deepEqual(
Photo.findAll(),
[
{
id: 1,
name: "Ski trip",
href: "ski-trip.jpeg",
is_public: false,
},
{
id: 2,
name: "Family photo",
href: "family-photo.jpeg",
is_public: true,
},
{
id: 3,
name: "Selfie",
href: null,
is_public: false,
},
{
id: 4,
name: "Imported photo",
href: "Imported photo",
is_public: false,
},
]
);

const target = Photo.insert({ name: 'Izel' });
t.deepEqual(Photo.findAll(), [
{
id: 1,
name: "Ski trip",
href: "ski-trip.jpeg",
is_public: false,
},
{
id: 2,
name: "Family photo",
href: "family-photo.jpeg",
is_public: true,
},
{
id: 3,
name: "Selfie",
href: null,
is_public: false,
},
{
id: 4,
name: "Imported photo",
href: "Imported photo",
is_public: false,
},
]);

const target = Photo.insert({ name: "Izel" });

t.deepEqual(target, {
id: 5,
name: "Izel",
href: "Izel",
is_public: true
is_public: true,
});
t.deepEqual(target, Photo.find(target.id));

const secondTarget = Photo.insert({ name: 'Izel', href: 'something else' });
const secondTarget = Photo.insert({ name: "Izel", href: "something else" });

t.deepEqual(secondTarget, {
id: 6,
name: "Izel",
href: "something else",
is_public: true
is_public: true,
});
t.deepEqual(secondTarget, Photo.find(secondTarget.id));

const thirdTarget = Photo.insert({ name: 'Izel', href: null });
const thirdTarget = Photo.insert({ name: "Izel", href: null });

t.deepEqual(thirdTarget, {
id: 7,
name: "Izel",
href: null,
is_public: true
is_public: true,
});
t.deepEqual(thirdTarget, Photo.find(thirdTarget.id));
}
Expand Down

0 comments on commit 368b7c7

Please sign in to comment.