Skip to content

Commit

Permalink
Merge branch 'main' of github.com:elhakimdev/typescript-abstract-data…
Browse files Browse the repository at this point in the history
…-type
  • Loading branch information
abdulelhakim68@gmail.com committed Jan 23, 2024
2 parents 84ea3f6 + 2d05052 commit 5d18718
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 30 deletions.
6 changes: 3 additions & 3 deletions src/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ export interface AbstractList<List> {
* @public
* @property
* @returns List
*
*
* @example
* ```
*
*
*
*
* ```
*/
getElement: () => List;
Expand Down
58 changes: 31 additions & 27 deletions test/list.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe("List", () => {
const data = new List<string>();
data.append("name");
data.append("value");

const persons = new List<Person>();
persons.append({
name: "hakim",
Expand All @@ -49,7 +49,7 @@ describe("List", () => {
},
];
persons.appends(personsdata);

expect(persons.size).toStrictEqual(2);
});
it("call ``remove()`` Should can be remove any givens element and return booleans, annd decrementing their size aautomatically", () => {
Expand All @@ -59,12 +59,14 @@ describe("List", () => {
age: 10,
});
expect(personList.size).toStrictEqual(1);
expect(personList.remove({ name: "hakim", age: 10 })).toStrictEqual(true);
expect(personList.remove({ name: "hakim", age: 10 })).toStrictEqual(
true,
);
expect(personList.size).toStrictEqual(0);
expect(personList.remove({ name: "hakim", age: 10 })).toStrictEqual(
false,
);

personList.append({
name: "hanan",
age: 20,
Expand Down Expand Up @@ -103,7 +105,7 @@ describe("List", () => {

expect(personLists.context[1]).toStrictEqual({
name: "insert",
age: 20
age: 20,
});
});
it("call ``insert()`` should can be insert element at correct position without passing ```after``` argument", () => {
Expand All @@ -130,7 +132,7 @@ describe("List", () => {

expect(personLists.context[2]).toStrictEqual({
name: "insert",
age: 20
age: 20,
});
expect(personLists.context[3]).toStrictEqual({
name: "insertTwo",
Expand All @@ -141,45 +143,47 @@ describe("List", () => {
describe("Iteration Methods Call", () => {
it("call `getEleemnt()`` Can be return a correct element for currennt position", () => {
const personLists = new List<Person>();

personLists.append({
name: "person1",
age: 20
})
age: 20,
});
personLists.append({
name: "person3",
age: 20
})
age: 20,
});
personLists.append({
name: "person3",
age: 20
})
age: 20,
});

expect(personLists.size).toStrictEqual(3);
expect(personLists.getElement()).toStrictEqual({
name: "person1",
age: 20
})
})
})
age: 20,
});
});
});
describe("Utils Methods Call", () => {
it("Call ``toString()`` should can return string represent the list", () => {
const personLists = new List<Person>();
personLists.append({
name: "person1",
age: 20
})
age: 20,
});
personLists.append({
name: "person3",
age: 20
})
age: 20,
});
personLists.append({
name: "person3",
age: 20
})
age: 20,
});

expect(personLists.toString()).toStrictEqual(JSON.stringify(personLists.context));
})
})
expect(personLists.toString()).toStrictEqual(
JSON.stringify(personLists.context),
);
});
});
});
});

0 comments on commit 5d18718

Please sign in to comment.