From 632e70ed711f4b8455d67200f3ef4dec0d48ab64 Mon Sep 17 00:00:00 2001 From: Bakhtier Gaibulloev Date: Wed, 4 Jun 2025 01:13:00 +0200 Subject: [PATCH] test(stack): cover peek on empty stack --- AGENTS.md | 35 +++++++++++++++++++++++++++++++++++ tests/HashMap/HashMap.spec.ts | 6 +++--- tests/Stack/Stack.spec.ts | 8 +++++++- 3 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 AGENTS.md diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..2c802cb --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,35 @@ +# Instructions for OpenAI Codex + +This file provides guidelines for OpenAI Codex to ensure code quality and consistency within this project. + +## General Instructions + +1. **Follow Existing Code Style**: Adhere to the style already present in the repository. +2. **Use TypeScript**: All new code must be written in TypeScript. +3. **Meaningful Names**: Use descriptive names for variables and functions. +4. **Comments**: Comment complex logic to explain its purpose. + +## Testing + +1. **Testing Framework**: Use Mocha and Chai for tests. +2. **Run Tests**: Compile the project then run `npm test` to execute all tests. +3. **Test Files**: Maintain and extend existing test files when adding new functionality. + +## Commands + +1. **Build**: `npm run build` +2. **Run All Tests**: `npm test` +3. **Watch Tests**: `npm run test_watch` +4. **Coverage**: `npm run cover` +5. **Lint**: `npx tslint -c tslint.json -p tsconfig.json` + +## Pull Request Guidelines + +1. **Description**: Provide a clear description of the changes. +2. **Related Issues**: Reference any related issues. +3. **Tests**: Ensure all tests pass before submission. +4. **Single Concern**: Keep pull requests focused on a single concern. + +## Important + +After making any changes, Codex MUST run `npm run build` and `npm test` to confirm that the build and tests pass. diff --git a/tests/HashMap/HashMap.spec.ts b/tests/HashMap/HashMap.spec.ts index 26e0919..846ecfd 100644 --- a/tests/HashMap/HashMap.spec.ts +++ b/tests/HashMap/HashMap.spec.ts @@ -123,9 +123,9 @@ describe('HashMap', () => { const result = map.values(); expect(result.length).to.equal(3); - expect(result.includes(42)).to.be.true; - expect(result.includes(99)).to.be.true; - expect(result.includes(123)).to.be.true; + expect(result).to.include(42); + expect(result).to.include(99); + expect(result).to.include(123); }); it('should return an empty array if the map is empty', () => { diff --git a/tests/Stack/Stack.spec.ts b/tests/Stack/Stack.spec.ts index 96f3ed4..f8c9981 100644 --- a/tests/Stack/Stack.spec.ts +++ b/tests/Stack/Stack.spec.ts @@ -20,12 +20,18 @@ describe('Stack', () => { }); - it('pop if stacl is empty', () => { + it('pop if stack is empty', () => { expect(stack.pop()).equal(null); }); + it('peek on empty stack', () => { + + expect(stack.peek()).equal(null); + + }); + it('peek', () => { stack.push(1);