mirrored_repositories/dipantau-desktop/test/feature/data/model
import 'dart:convert';

import 'package:dipantau_desktop_client/feature/data/model/track_user_lite/track_user_lite_response.dart';
import 'package:flutter_test/flutter_test.dart';

import '../../../../fixture/fixture_reader.dart';

void main() {
  const tPathJson = 'track_user_lite_response.json';
  final tModel = TrackUserLiteResponse.fromJson(
    json.decode(
      fixture(tPathJson),
    ),
  );

  test(
    'pastikan output dari nilai props',
    () async {
      // assert
      expect(
        tModel.props,
        [
          tModel.projectId,
          tModel.projectName,
          tModel.trackedInSeconds,
          tModel.listTracks,
          tModel.listTasks,
        ],
      );
    },
  );

  test(
    'pastikan output dari fungsi toString',
    () async {
      // assert
      expect(
        tModel.toString(),
        'TrackUserLiteResponse{projectId: ${tModel.projectId}, projectName: ${tModel.projectName}, '
        'trackedInSeconds: ${tModel.trackedInSeconds}, listTracks: ${tModel.listTracks}, '
        'listTasks: ${tModel.listTasks}}',
      );
    },
  );

  test(
    'pastikan fungsi fromJson bisa mengembalikan objek class model',
    () async {
      // arrange
      final jsonData = json.decode(
        fixture(tPathJson),
      );

      // act
      final actualModel = TrackUserLiteResponse.fromJson(jsonData);

      // assert
      expect(actualModel, tModel);
    },
  );

  test(
    'pastikan fungsi toJson bisa mengembalikan objek map',
    () async {
      // arrange
      final model = TrackUserLiteResponse.fromJson(
        json.decode(
          fixture(tPathJson),
        ),
      );

      // act
      final actualMap = json.encode(model.toJson());

      // assert
      expect(actualMap, json.encode(tModel.toJson()));
    },
  );
}
