Skip to content

Write unit tests for queries

Feature ID FEA021
Subsystem the feature is part of Backend
Responsible person Developers
Status Implemented

Description

Writing of tests for each section of the application.

Use Case 1 Running unit tests to make sure a section of the application runs as intended
FUNC-REQ-C0020 FUNC-REQ-C0020

Preliminary user stories

  • #27 As a IoTitude tester , I want to see the documentation of the previous tests so that I know more about the problems that the product may have had.
  • #53 As a customer, I want to see some kind of statistics of tests ran so that we know it's been tested

User interface mock-up

// user.ts
function getUserFullName(firstName: string, lastName: string): string {
  return `${firstName} ${lastName}`;
}

// user.test.ts
describe('getUserFullName function', () => {
  it('should concatenate the first name and last name correctly', () => {
    const fullName = getUserFullName('John', 'Doe');
    expect(fullName).toBe('John Doe');
  });

  it('should handle empty strings gracefully', () => {
    const fullName = getUserFullName('', 'Doe');
    expect(fullName).toBe(' Doe');
  });

  it('should handle special characters in names', () => {
    const fullName = getUserFullName('John', 'D@e');
    expect(fullName).toBe('John D@e');
  });
});

Testing / possible acceptance criteria

  • Developers prove that they have done unit tests